<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * Logging Class
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category	Logging
 * @author		ExpressionEngine Dev Team
 * @link		http://codeigniter.com/user_guide/general/errors.html
 */
class CI_File_manager {

	protected $_debug			= TRUE;
	protected $_accepted_ext 	= array("png", "jpg", "gif");

	// http://your-web-site.domain/base/url
	protected $_base_url 		= '/uploads';
	// the root path of the upload directory on the server
	// protected $_uploads_dir 	= realpath("./uploads");

	// the root path that the files are available from the webserver
	// YOU WILL NEED TO CHANGE THIS
	protected $_uploads_access_dir = "uploads/";

	/**
	 * Constructor
	 */
	public function __construct($opt = array())
	{
		print_r($opt);
		$config =& get_config();
		$this->_uploads_access_dir = $opt['uploads_access_dir'] || $this->_uploads_access_dir;
		$this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/';

		if ($this->_debug) {
			error_reporting(E_ALL | E_NOTICE | E_STRICT);
			ini_set('display_errors', 'On');
			ini_set('display_startup_errors', 'On');

			$error_log_file = $this->_log_path . '/errors.log';

			// Test if error log is writable.
			$error = '';
			if (file_exists($error_log_file) && !is_writable($error_log_file)) {
				$error = 'Make file "' . $error_log_file . '" writable or set debug to false.';
			} else if (!file_exists($error_log_file) && !is_writable(dirname($error_log_file))) {
				$error = 'Make dir "' . dirname($error_log_file) . '" writable or set debug to false.';
			}
			if ($error) {
				header('Content-type: text/html; charset=UTF-8');
				print('{"error":"file-manager.php: ' . htmlentities($error) . '","success":false}');
				exit();
			}

			ini_set('error_log', $error_log_file);
			ini_set('log_errors', 'On');
		}

		if (extension_loaded('mbstring')) {
			mb_internal_encoding('UTF-8');
			mb_regex_encoding('UTF-8');
		}

		if ($this->_debug) {
			if (!file_exists($this->_uploads_access_dir)) {
				$error = 'Folder "' . $this->_uploads_access_dir . '" doesn\'t exists.';

				header('Content-type: text/html; charset=UTF-8');
				print('{"error":"config.php: ' . htmlentities($error) . '","success":false}');
				exit();
			}
		}
	}	
}

// END Log Class

/* End of file Log.php */
/* Location: ./system/libraries/Log.php */
?>